package com.shawn.model.vo;

import com.shawn.model.entity.UserInfo;
import com.shawn.model.mongo.Visitors;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class VisitorsVo implements Serializable {
    private Integer id;//访客用户id 1
    private String avatar; //访客用户头像地址
    private String nickname;//访客用户昵称
    private String gender;//访客用户性别 man woman
    private Integer age;//年龄
    private String[] tags;//标签 1
    private Integer fateValue;//缘分值 2

    public static VisitorsVo init(UserInfo userInfo, Visitors visitors){
        VisitorsVo vo = new VisitorsVo();
        BeanUtils.copyProperties(userInfo,vo);
        vo.setId(Math.toIntExact(userInfo.getId()));
        String tags = userInfo.getTags();
        if (tags!=null){
            vo.setTags(tags.split(","));
        }
        vo.setFateValue(visitors.getScore().intValue());
        return vo;
    }
}
